import pymysql
import xlwt

def exe_db():
    # 打开数据库连接，不指定数据库
    conn = pymysql.connect(host='rm-2vc8ph19y245ogz5hzo.mysql.cn-chengdu.rds.aliyuncs.com', port=3306, user='labi_user', password='648@QETR$!')
    # conn = pymysql.connect(host='139.155.88.162', port=3306, user='root', password='xuhuan.59')
    conn.select_db('linjiashop_backups')
    cur = conn.cursor()  # 获取游标

    try:
        # print("===========================================================================================================")
        print("通知系统开始查询订单")
        cur.execute("select * from t_shop_order where (status>1 and status<=4)")  # 1未付款 2未发货 3已发货 4已完成
        # 使用 fetchone() 方法获取一条数据
        data = cur.fetchall()

        if data:
            for row in data:
                pass
        conn.commit()
    finally:
        try:
            cur.close()
            conn.close()
        except Exception as e1:
            print('sql执行成功异常：' + str(e1))


if __name__ == '__main__':
    exe_db()